

<template>
  <div>
        <basic-container>
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>打包管理</el-breadcrumb-item>
        <el-breadcrumb-item>项目管理</el-breadcrumb-item>
      </el-breadcrumb>
    </basic-container>
    <basic-container>
      <avue-crud
        ref="crud"
        :data="data"
        v-model="form"
        :option="option"
        :page.sync="page"
        @on-load="getList"
        @refresh-change="refreshChange"
        @search-reset="from = {}"
      >
        <!-- 自定义按钮 -->
        <template slot="pack" slot-scope="scope">
          <el-row>
            <el-button type="primary" size="small" @click="openpack(scope.row)"
              >打包</el-button
            >
          </el-row>
        </template>
        <!-- 自定义按钮 -->
        <template slot="download" slot-scope="scope">
          <el-row>
              <el-button type="success" size="small" @click="downloadpackage(scope.row)">下载</el-button>
          </el-row>
        </template>
        <template slot-scope="{ type, size }" slot="menu">
          <el-button
            :size="size"
            :type="type"
            @click="$router.push('/orangecatversionpromotion/channelmanager')"
            >渠道列表</el-button
          >
        </template>
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
import { catUrl } from "@/config/env";
import { common } from "@/api/cat/httpRequest";
import { appProjectPackManage as baseUrl } from "@/api/cat/baseUrls";
export default {
  data() {
    return {
      page: {
        total: 0,
        pageSize: 10,
      },
      type: true,
      data: [],
      params: {},
      form: {},
      option: {
        selection: true,
border: true,
        delBtn: false,
        editBtn: false,
        searchBtn: false,
        addBtn: false,
        column: [
          {
            label: "项目ID",
            prop: "app_id",
            type: "input",
            addDisplay: false,
            editDisplay: false,
            addDisabled: true,
            editDisabled: true,
            readonly: true,
          },
          {
            label: "项目名称",
            prop: "app_name",
            type: "input",
            required: true,
            addDisplay: false,
            editDisplay: false,
            addDisabled: true,
            editDisabled: true,
            readonly: true,
          },
          // {
          //   label: "项目渠道标识",
          //   prop: "app",
          //   type: "input",
          //   required: true,
          // },
          {
            label: "渠道总数",
            prop: "channel_num",
            type: "input",
            required: true,
          },
          {
            label: "创建日期",
            prop: "create_time",
            type: "input",
          },
          {
            label: "批量打包",
            prop: "pack",
            type: "select",
            slot: true,
          },
          {
            label: "下载包",
            prop: "download",
            type: "input",
            required: true,
            slot: true,
          },
        ],
      },
    };
  },
  methods: {
    /**获取列表 */
    async getList() {
      this.loading = true;
      //清空表格列表
      this.data = [];
      this.params.orderByList = "create_time&DESC";
      //发送请求获取数据
      let response = await common(
        `${baseUrl.pageAndParam}`,
        { ...this.params, ...this.defalut },
        this.page,
        "POST"
      );

      this.page = response.page;
      this.data = response.data;
      this.loading = false;
    },
    /**刷新 */
    refreshChange() {
      this.getList();
    },
    openpack(row) {
      this.$router.push({
        path: "/project/channelbatchpack",
        query: {
          app_id: row.app_id,
          preRouter: this.$route.path,
        },
      });
    },
    downloadpackage(){
      this.$router.push({
        path: "/projectpack/projectdownload",
        query: {
          preRouter: this.$route.path,
        }
      })
    }
  },
};
</script>